
<template>
    <div style="height: 100%; width: 100%; position: relative;" ref="maindev">
        <div class="pagetop">
            <table style="width: 100%; font-size: 12px;" border="0">
                <tr>
                    <td>快速查找</td>
                    <td>
                        <div style="width:200px;">
                            <el-input v-model="txtsearch" width="200px" placeholder="患者姓名|患者编号"></el-input>
                        </div>

                    </td>
                    <td style="align-text:right">
                        <el-button v-show="!bChangeFlag" @click="refreshdata" icon="el-icon-refresh">刷新</el-button>
                        <el-button @click.native="btnAdd" v-has="'PADD'" v-show="!bChangeFlag" icon="el-icon-plus">新增</el-button>
                        <el-button @click.native="btnUpd" v-has="'PMODIFY'" v-show="!bChangeFlag" icon="el-icon-edit">修改</el-button>
                        <el-button @click.native="btnDel" v-has="'PDELETE'" v-show="!bChangeFlag" icon="el-icon-delete">删除</el-button>
                        <el-button @click="btnSave" icon="el-icon-document" v-has="'PMODIFY'" v-show="bChangeFlag" :disabled="!bChangeFlag">保存</el-button>
                        <el-button @click="btnCancel" icon="el-icon-close" v-show="bChangeFlag" :disabled="!bChangeFlag">取消</el-button>
                        <el-button @click.native="btnSetup" v-has="'PSETUP'" icon="el-icon-setting">设置</el-button>
                    </td>
                </tr>
            </table>
        </div>
        <div class="pagecenter">
            <rm-layout-left :fixsize="200" :splitwidth="5" :minfixsize="200" :maxflxsize="2000">
                <template v-slot:fix>
                    <div style="height:100%;border:1px solid #CCC">
                        <el-tree :data="specialtypeData" :props="defaultProps" :default-expand-all="true" :highlight-current="true" @node-click="specialtypechange_Event"></el-tree>
                    </div>
                </template>
                <template>
                    <rm-layout-right splitcolor="#ffffff" :splitwidth="2" :fixsize="475" :minfixsize="200" ref="layoutright">
                        <vxe-table :data.sync="list" :loading="specialpatLoading" :select-config="{reserve: true}" :sort-config="{trigger: 'cell'}" border height="auto" highlight-current-row highlight-hover-column :cell-class-name="cellClassName" :row-class-name="rowClassName" highlight-hover-row how-header-overflow ref="specialpatTable" resizable show-overflow size="mini" show-header-overflow :optimization="{animat: false}" @current-change="specialpatchange_Event" header-align="center">
                            <vxe-table-column field="pat_name" sortable title="病人姓名" width="130" show-overflow></vxe-table-column>
                            <vxe-table-column field="pat_no" sortable title="病历号" width="130" show-overflow></vxe-table-column>
                            <vxe-table-column field="pat_id" sortable title="病人ID" width="130" show-overflow></vxe-table-column>
                            <vxe-table-column field="inp_id" sortable title="就诊号" width="130" show-overflow></vxe-table-column>
                            <vxe-table-column field="pat_cardno" sortable title="就诊卡号" width="130" show-overflow></vxe-table-column>
                            <vxe-table-column field="pat_idcardno" sortable title="身份证号" width="130" show-overflow></vxe-table-column>
                            <vxe-table-column field="specialtypename" sortable title="病人类型" width="130" show-overflow></vxe-table-column>
                            <vxe-table-column field="validflag" sortable title="状态" width="50" show-overflow>
                                <template v-slot="{ row }">
                                    <span>{{row.validflag=='1'?'有效':'无效'}}</span>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="mark_dt" :formatter="['toDateString', 'yyyy-MM-dd']" sortable title="标记时间" width="130" show-overflow></vxe-table-column>
                            <vxe-table-column field="mark_userno" sortable title="标记人" width="130" show-overflow></vxe-table-column>
                            <vxe-table-column field="expire_dt" sortable title="有效期" width="130" :formatter="['toDateString', 'yyyy-MM-dd']" show-overflow></vxe-table-column>
                            <vxe-table-column field="note" sortable title="备注信息" width="130" show-overflow></vxe-table-column>
                        </vxe-table>
                        <template v-slot:fix>
                            <div class="right-inser" style="height:100%;border:1px solid #CCC">
                                <table class="table1style" style="font-size:12px;width:100%">
                                    <tr>
                                        <td style="color:red;">患者姓名</td>
                                        <td>
                                            <el-input ref="input11" style="width: 100%" v-model="detailData.pat_name" :disabled="!bChangeFlag" @keyup.enter.native="nextFocus(1, 1)"></el-input>
                                        </td>
                                        <td>病历号</td>
                                        <td>
                                            <el-input style="width: 100%" ref="input12" v-model="detailData.pat_no" :disabled="!bChangeFlag" @keyup.enter.native="nextFocus(1, 2)"></el-input>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>病人ID</td>
                                        <td>
                                            <el-input style="width: 100%" ref="input13" v-model="detailData.pat_id" :disabled="!bChangeFlag" @keyup.enter.native="nextFocus(1, 3)"></el-input>
                                        </td>
                                        <td>身份证号</td>
                                        <td>
                                            <el-input style="width: 100%" ref="input14" v-model="detailData.pat_idcardno" :disabled="!bChangeFlag" @keyup.enter.native="nextFocus(1, 4)"></el-input>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>就诊号</td>
                                        <td>
                                            <el-input style="width: 100%" ref="input15" v-model="detailData.inp_id" :disabled="!bChangeFlag" @keyup.enter.native="nextFocus(1, 5)"></el-input>
                                        </td>
                                        <td>就诊卡号</td>
                                        <td>
                                            <el-input style="width: 100%" ref="input16" v-model="detailData.pat_cardno" :disabled="!bChangeFlag" @keyup.enter.native="nextFocus(1, 6)"></el-input>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="color:red;">病人类型</td>
                                        <td>
                                            <el-select v-model="detailData.specialtype" ref="input17" placeholder="请选择" style="width: 100%" :disabled="!bChangeFlag" @keyup.enter.native="nextFocus(1, 7)">
                                                <el-option v-for="item in specialtypeOption" :key="item.value" :label="item.label" :value="item.value"></el-option>
                                            </el-select>
                                        </td>
                                        <td>标记时间</td>
                                        <td>
                                            <el-date-picker style="width: 100%" v-model="detailData.mark_dt" :disabled="true"></el-date-picker>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>标记人</td>
                                        <td>
                                            <el-input style="width: 100%" v-model="detailData.mark_userno" :disabled="true"></el-input>
                                        </td>
                                        <td>有效期</td>
                                        <td>
                                            <el-date-picker style="width: 100%" ref="input18" v-model="detailData.expire_dt" :disabled="!bChangeFlag" @keyup.enter.native="nextFocus(1, 8)"></el-date-picker>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>状态</td>
                                        <td>
                                            <el-select v-model="detailData.validflag" style="width: 100%" :disabled="!bChangeFlag" ref="validflag">
                                                <el-option label="有效" value="1"></el-option>
                                                <el-option label="无效" value="0"></el-option>
                                            </el-select>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>备注信息</td>
                                        <td colspan="3">
                                            <el-input type="textarea" ref="input19" :rows="2" :disabled="!bChangeFlag" v-model="detailData.note">
                                            </el-input>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </template>
                    </rm-layout-right>
                </template>
            </rm-layout-left>
            <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="特殊病人标记类型" :visible.sync="settingvisible" v-if="settingvisible" width="960px">
                <div style="height:100%;position:relative;width:100%">
                    <div style="width:100%">
                        <vxe-table :data="specialtypeList" :edit-config="{trigger: 'click', mode: 'cell',showStatus: true,showIcon:false}" border height="300px" highlight-current-row highlight-hover-row resizable size="mini" stripe style="margin-top:10px" :header-cell-class-name="headerCellClassName" header-align="center" align="center" ref="specialtypeTable" width="100%" :select-config="{reserve: true}" :edit-rules="validRules">
                            <vxe-table-column field="selection" type="selection" width="40"></vxe-table-column>
                            <vxe-table-column field="specialtype" title="类型代码" width="100px" :edit-render="{name: 'input',autoselect:true}"></vxe-table-column>
                            <vxe-table-column field="specialtypename" title="类型名称" width="120px" :edit-render="{name: 'input',autoselect:true}"></vxe-table-column>
                            <vxe-table-column field="specialtypena" title="类型简称" width="90px" :edit-render="{name: 'input',autoselect:true}"></vxe-table-column>
                            <vxe-table-column field="tip_collect" title="门诊采样弹窗提醒" width="60px">
                                <template v-slot="{ row }">
                                    <el-checkbox v-model="row.tip_collect" v-if="row.tip_collect == '0'" true-label="1" false-label="0" :key="0"></el-checkbox>
                                    <el-checkbox v-model="row.tip_collect" v-else checked="checked" true-label="1" false-label="0" :key="1"></el-checkbox>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="tip_recieve" title="标本签收弹窗提醒" width="60px">
                                <template v-slot="{ row }">
                                    <el-checkbox v-model="row.tip_recieve" v-if="row.tip_recieve == '0'" true-label="1" false-label="0" :key="0"></el-checkbox>
                                    <el-checkbox v-model="row.tip_recieve" v-else checked="checked" true-label="1" false-label="0" :key="1"></el-checkbox>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="tip_bact" title="无纸化微生物弹窗提醒" width="80px">
                                <template v-slot="{ row }">
                                    <el-checkbox v-model="row.tip_bact" v-if="row.tip_bact == '0'" true-label="1" false-label="0" :key="0"></el-checkbox>
                                    <el-checkbox v-model="row.tip_bact" v-else checked="checked" true-label="1" false-label="0" :key="1"></el-checkbox>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="tip_input" title="报告录入弹窗提醒" width="60px">
                                <template v-slot="{ row }">
                                    <el-checkbox v-model="row.tip_input" v-if="row.tip_input == '0'" true-label="1" false-label="0" :key="0"></el-checkbox>
                                    <el-checkbox v-model="row.tip_input" v-else checked="checked" true-label="1" false-label="0" :key="1"></el-checkbox>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="noalert" title="不上报危急值" width="50px">
                                <template v-slot="{ row }">
                                    <el-checkbox v-model="row.noalert" v-if="row.noalert == '0'" true-label="1" false-label="0" :key="0"></el-checkbox>
                                    <el-checkbox v-model="row.noalert" v-else checked="checked" true-label="1" false-label="0" :key="1"></el-checkbox>
                                </template>
                            </vxe-table-column>
                            <!-- <vxe-table-column field="noabnresult" title="不计算异常结果" width="60px">
                                                <template v-slot="{ row }">
                                                    <el-checkbox v-model="row.noabnresult" v-if="row.noabnresult == '0'" true-label="1" false-label="0" :key="0"></el-checkbox>
                                                    <el-checkbox v-model="row.noabnresult" v-else checked="checked" true-label="1" false-label="0" :key="1"></el-checkbox>
                                                </template>
                                            </vxe-table-column> -->
                            <vxe-table-column field="noreleasereport" title="不执行发布报告" width="60px">
                                <template v-slot="{ row }">
                                    <el-checkbox v-model="row.noreleasereport" v-if="row.noreleasereport == '0'" true-label="1" false-label="0" :key="0"></el-checkbox>
                                    <el-checkbox v-model="row.noreleasereport" v-else checked="checked" true-label="1" false-label="0" :key="1"></el-checkbox>
                                </template>
                            </vxe-table-column>
                            <!-- <vxe-table-column field="querylimit" title="限制查询" width="40px">
                                                <template v-slot="{ row }">
                                                    <el-checkbox v-model="row.querylimit" v-if="row.querylimit == '0'" true-label="1" false-label="0" :key="0"></el-checkbox>
                                                    <el-checkbox v-model="row.querylimit" v-else checked="checked" true-label="1" false-label="0" :key="1"></el-checkbox>
                                                </template>
                                            </vxe-table-column> -->
                            <vxe-table-column field="bactvip" title="无纸化微生物VIP标记" width="80px">
                                <template v-slot="{ row }">
                                    <el-checkbox v-model="row.bactvip" v-if="row.bactvip == '0'" true-label="1" false-label="0" :key="0"></el-checkbox>
                                    <el-checkbox v-model="row.bactvip" v-else checked="checked" true-label="1" false-label="0" :key="1"></el-checkbox>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="reportdiagred" title="特殊诊断标记" width="50px">
                                <template v-slot="{ row }">
                                    <el-checkbox v-model="row.reportdiagred" v-if="row.reportdiagred == '0'" true-label="1" false-label="0" :key="0"></el-checkbox>
                                    <el-checkbox v-model="row.reportdiagred" v-else checked="checked" true-label="1" false-label="0" :key="1"></el-checkbox>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="retspecimen" title="标本回收" width="40px">
                                <template v-slot="{ row }">
                                    <el-checkbox v-model="row.retspecimen" v-if="row.retspecimen == '0'" true-label="1" false-label="0" :key="0"></el-checkbox>
                                    <el-checkbox v-model="row.retspecimen" v-else checked="checked" true-label="1" false-label="0" :key="1"></el-checkbox>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="rptdealspecialflag" title="报告处理界面特殊标记" width="76px">
                                <template v-slot="{ row }">
                                    <el-checkbox v-model="row.rptdealspecialflag" v-if="row.rptdealspecialflag == '0'" true-label="1" false-label="0" :key="0"></el-checkbox>
                                    <el-checkbox v-model="row.rptdealspecialflag" v-else checked="checked" true-label="1" false-label="0" :key="1"></el-checkbox>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="rptdealcolor" title="报告处理界面颜色" width="80px">
                                <template v-slot="{ row }">
                                    <el-color-picker v-model="row.rptdealcolor"></el-color-picker>
                                </template>
                            </vxe-table-column>
                        </vxe-table>
                    </div>
                    <div style="text-align:right;width:100%">
                        <el-button @click="addspecialtype()" style="margin-top: 10px;margin-left:10px" icon="el-icon-plus">新 增</el-button>
                        <el-button @click="delspecialtype()" style="margin-top: 10px;margin-left:10px" icon="el-icon-delete">删 除</el-button>
                        <el-button @click="savespecialtype()" icon="el-icon-document" style="margin-top: 10px;margin-left:10px">保 存</el-button>
                        <el-button @click="settingvisible = false" icon="el-icon-close" style="margin-top: 10px;margin-left:10px">退 出</el-button>
                    </div>
                </div>
            </el-dialog>
        </div>
    </div>
</template>

<script type="text/javascript">
import XEUtils from "xe-utils";
import rmLayoutLeft from '../../../rmcompents/rm-layout-left.vue';
export default {
    components: { rmLayoutLeft },
    name: "MNG227",
    data() {
        return {
            bChangeFlag: false,
            specialtypeLoading: false,
            specialpatLoading: false,
            settingvisible: false,
            specialtypeOption: [],
            specialtypeList: [],
            specialtypeData: [],
            specialpatList: [],
            detailData: {},
            selrow: {},
            specialtype: "",
            operationtype: 0,
            txtsearch: '',
            defaultProps: {
                children: 'children',
                label: 'label',
                value: 'value'
            },
            validRules: {
                specialtype: [{ required: true, message: "类型代码不能为空！" }],
                specialtypename: [{ required: true, message: "类型名称不能为空！" }],
            },
        };
    },
    updated() {
    },
    created() {
        this.GetOptions();
        this.BtnQuery();
    },
    computed: {
        //模糊查询  名称|首拼
        list() {
            let filterName = this.txtsearch.trim();
            if (filterName) {
                let rest = this.specialpatList.filter((item) => {
                    return (
                        item.pat_no.toLowerCase().indexOf(filterName.toLowerCase()) > -1 ||
                        (item.pat_name ? item.pat_name.toLowerCase().indexOf(filterName.toLowerCase()) > -1 : false)
                    );
                });
                return rest;
            } else {
                return this.specialpatList;
            }
        },
    },
    methods: {
        refreshdata() {
            this.GetOptions();
            this.BtnQuery();
            this.detailData = {};
        },
        //特殊病人标记
        GetOptions() {
            this.specialtypeLoading = true;
            this.$tool
                .request({
                    url: "MNG/MNG2/MNG227",
                    method: "post",
                    data: {
                        action: "getoptions",
                    },
                })
                .then((res) => {
                    this.specialtypeOption = res.option;
                    this.specialtypeData = res.data;
                    if (this.specialtypeData && this.specialtypeData.length > 0) {
                        this.specialtype = this.specialtypeData[0].value;
                    }
                    this.specialtypeLoading = false;
                })
                .catch((e) => {
                    this.labLoading = false;
                    console.log("error", e);
                });
        },
        /****************  按钮类 ********************/
        //查询
        async BtnQuery() {
            this.specialpatLoading = true;
            this.$tool
                .request({
                    url: "MNG/MNG2/MNG227",
                    method: "post",
                    timeout: 600000,
                    data: {
                        action: "query",
                        specialtype: this.specialtype
                    },
                })
                .then((res) => {
                    this.specialpatList = res.data;
                    this.specialpatLoading = false;
                    if (this.specialpatList && this.specialpatList.length > 0) {
                        this.$refs.specialpatTable.setCurrentRow(this.specialpatList[0]);
                        this.selrow = this.$refs.specialpatTable.getCurrentRow();
                        this.detailData = XEUtils.clone(this.specialpatList[0], true);
                    }
                })
                .catch((e) => {
                    this.specialpatLoading = false;
                    this.$message.error(e);
                });
        },
        btnUpd() {
            if (this.detailData.pat_name == '') {
                this.$message.info('请先选择一条数据。');
            } else {
                this.operationtype = 2;
                this.bChangeFlag = true;
            }
        },
        btnAdd() {
            this.bChangeFlag = true;
            this.operationtype = 1;
            this.detailData = {
                validflag: '1',
                specialtype: this.specialtype
            };
        },
        //保存
        async btnSave() {
            if (!this.detailData.specialtype) {
                this.$alert('病人类型不能为空！');
                this.$refs.input17.focus();
                return false;
            }
            if (!this.detailData.pat_name) {
                this.$alert('患者姓名不能为空！');
                this.$refs.input11.focus();
                return false;
            }
            try {
                const res = await this.$tool.request({
                    url: 'MNG/MNG2/MNG227',
                    method: 'post',
                    data: {
                        action: 'save',
                        data: this.detailData,
                    },
                });
                if (res.flag == '1') {
                    this.$message.success('保存成功！');
                    if (this.operationtype == 1) {
                        res.obj.operationtype = 1;
                        res.obj.specialtypename = this.specialtypeOption.find(x => x.value == res.obj.specialtype).label;
                        this.$refs.specialpatTable.insert(res.obj).then(({ row }) => {
                            this.$refs.specialpatTable.setCurrentRow(row).then(() => {
                                this.selrow = this.$refs.specialpatTable.getCurrentRow();
                            });
                        });
                        this.specialpatList.push(res.obj);
                        console.log(this.specialpatList);
                    }
                    if (this.operationtype == 2) {
                        var fcurmedium = this.specialpatList.filter(t => t.specialpatid == this.selrow.specialpatid)
                        this.detailData.operationtype = 2;
                        Object.keys(this.detailData).forEach(key => {
                            if (this.selrow.hasOwnProperty(key)) {
                                this.selrow[key] = this.detailData[key];
                                fcurmedium[0][key] = this.detailData[key];
                            }
                        })
                    }
                    this.$refs.specialpatTable.setCurrentRow(this.detailData);
                    this.bChangeFlag = false;
                } else {
                    this.$message({ message: res.msg, type: 'error' });
                }
            } catch (e) {
                console.log(e);
                this.$message({ message: e, type: 'error' });
            }
        },
        btnCancel() {
            this.$confirm('您确定要取消这次改动吗？', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            })
                .then(() => {
                    this.bChangeFlag = false;
                })
                .catch((e) => { });
        },
        btnDel() {
            this.detailData = XEUtils.clone(this.$refs.specialpatTable.getCurrentRow(), true);
            if (this.detailData == null) {
                this.$message.info('请先选择一条数据。');
                return false;
            }
            this.$confirm(`您确定要删除[${this.detailData.pat_name}]吗？`, {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(() => {
                    this.btnDelComfirm(this.detailData.specialpatid);
                })
                .catch((e) => { });

        },
        btnDelComfirm() {
            this.$tool
                .request({
                    url: 'MNG/MNG2/MNG227',
                    method: 'post',
                    data: {
                        action: 'del',
                        specialpatid: this.detailData.specialpatid,
                    },
                })
                .then((res) => {
                    if (res.flag == '1') {
                        this.$message.success('删除成功！');
                        var delrow = this.$refs.specialpatTable.getCurrentRow();
                        this.$refs.specialpatTable.remove(delrow);
                        this.detailData = {};
                    } else {
                        this.$message.error('删除失败！' + res.obj);
                    }
                })
                .catch((e) => {
                    this.$message.error(e);
                });
        },
        btnSetup() {
            this.$tool
                .request({
                    url: "MNG/MNG2/MNG227",
                    method: "post",
                    timeout: 600000,
                    data: {
                        action: "querytype",
                    },
                })
                .then((res) => {
                    this.specialtypeList = res.data;
                    this.settingvisible = true;
                })
                .catch((e) => {
                    this.settingvisible = true;
                    this.$message.error(e);
                });
        },
        specialpatchange_Event({ row, rowIndex, column, columnIndex }, event) {
            if (this.bChangeFlag) {
                // 点击切换之前的 row
                this.$refs.specialpatTable.setCurrentRow(this.selrow);
                return false;
            }
            this.$refs.specialpatTable.setCurrentRow(row);
            this.selrow = this.$refs.specialpatTable.getCurrentRow();
            this.detailData = XEUtils.clone(row, true);
        },
        specialtypechange_Event(val) {
            if (this.bChangeFlag) {
                this.$message.warning("编辑状态无法切换！");
                return false;
            }
            this.specialtype = val.value;
            this.BtnQuery();
        },
        headerCellClassName({ column, columnIndex }) {
            if (column.property != 'specialtype' && column.property != 'specialtypename'&& column.property != 'specialtypena' && column.property != 'selection') {
                return 'headtop';
            }
        },
        rowClassName({ row, rowIndex }) {
            let isDirty = this.$refs.specialpatTable.hasRowChange(row);
            if (isDirty) {
                return "row-modify";
            }
            if (row.operationtype == 1) {
                return "row-new";
            }
        },
        addspecialtype() {
            let record = {
                specialtype: '',
                specialtypename: '',
                specialtypena: '',
                tip_collect: 0,
                tip_recieve: 0,
                tip_bact: 0,
                tip_input: 0,
                noalert: 0,
                noabnresult: 0,
                noreleasereport: 0,
                queryLimit: 0,
                reportdiagred: 0,
                retspecimen: 0,
                bactvip: 0,
                rptdealspecialflag: 0,
                rptdealcolor: "#FF0000",
            };
            this.$refs.specialtypeTable.insert(record).then((row) => {
                this.$refs.specialtypeTable.setCurrentRow(row.row);
                this.$refs.specialtypeTable.setActiveCell(row.row, "specialtype");
            });
        },
        delspecialtype() {
            let removeRecords = this.$refs.specialtypeTable.getSelectRecords();
            if (removeRecords.length <= 0) {
                this.$message.error("请先选择数据！");
                return false;
            }
            this.$confirm("此操作将删除所选数据, 是否继续?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(() => {
                    this.$refs.specialtypeTable.removeSelecteds();
                    this.savespecialtype(); //直接调用删除参考值明细
                })
                .catch(() => { });
        },
        savespecialtype() {
            let removeRecords = this.$refs.specialtypeTable.getRemoveRecords();
            let updateRecords = this.$refs.specialtypeTable.getUpdateRecords();
            let insertRecords = this.$refs.specialtypeTable.getInsertRecords();
            var a = insertRecords.filter(x => {
                return x.specialtype == "" || x.specialtypename == ""
            })
            if (a.length > 0)
                a.forEach(x => {
                    this.$refs.specialtypeTable.remove(x);
                })
            this.$refs.specialtypeTable.validate(valid => {
                if (valid) {
                    this.$tool
                        .request({
                            url: "MNG/MNG2/MNG227",
                            method: "post",
                            data: {
                                action: "savespecialtype",
                                removeRecords: removeRecords,
                                updateRecords: updateRecords,
                                insertRecords: insertRecords,
                            },
                        })
                        .then((res) => {
                            if (res.flag == "1") {
                                this.$message.success("保存成功！");
                                this.btnSetup();
                                this.GetOptions();
                            } else {
                                this.$message.error(res.msg);
                                this.btnSetup();
                            }
                        })
                        .catch((e) => {
                            this.$message.error(e);
                        });
                } else {
                    this.$message({ type: 'error', message: '校验不通过！' })
                }
            })
        },
        cellClassName({ row, column }) {
            if (column.property == 'validflag')
                if (row['validflag'] != '1')
                    return 'colred';
        },
        // 回车切换输入框
        nextFocus(id, index) {
            if (index <= 9) {
                var that = this;
                var focusIndex = index + 1;
                setTimeout(function () {
                    that.$refs['input' + id + focusIndex].focus()
                }, 1)
            }
        },
    },
};
</script>

<style scoped>
.pagetop {
    width: 100%;
    height: 36px;
    display: -webkit-box;
    -webkit-box-pack: center;
    -webkit-box-align: center;
    border: 1px solid #ccc;
    position: absolute;
    z-index: 99;
}
.pagecenter {
    position: absolute;
    top: 40px;
    width: 100%;
    left: 0;
    bottom: 0px;
    overflow: auto;
}
.middle-center {
    position: absolute;
    height: 100%;
    left: 0px;
    right: 0px;
    overflow: auto;
}
.right-inser {
    position: absolute;
    top: 0;
    bottom: 0px;
    overflow: auto;
    width: 100%;
    right: 0px;
}
.middle-tab-top {
    position: absolute;
    top: 0px;
    width: 100%;
    height: 200px;
}
table tr td:nth-child(odd) {
    text-align: right;
    white-space: nowrap;
}
table tr td:nth-child(even) {
    text-align: left;
}
table tr td:nth-child(1) {
    width: 80px;
}
table {
    font-size: 12px;
}
.table1style tr td {
    padding: 0px 2px 0px 2px;
}
::v-deep .headtop {
    vertical-align: top !important;
}
::v-deep .colred {
    background-color: red !important;
}
::v-deep .colgreen {
    background-color: #00ff00 !important;
}
::v-deep .colrow {
    background-color: #c0ffc0;
}
::v-deep .mytable-style .vxe-body--row.row-blue {
    color: rgb(157, 158, 161) !important;
    font-weight: bold;
}
::v-deep .el-icon-time {
    line-height: 18px !important;
}
::v-deep.el-range__close-icon {
    line-height: 18px !important;
}
::v-deep.el-input--suffix .el-input__inner {
    padding-right: 0px;
}
::v-deep.el-checkbox__label {
    display: inline-block;
    font-size: 12px;
}
::v-deep.vxe-table .vxe-cell {
    padding: 0 3px 0 3px !important;
}
::v-deep tr.vxe-body--row.row--current {
    color: #000000;
    font-weight: bold;
}
::v-deep .vxe-table .vxe-body--column.col-blue {
    color: blue;
}
::v-deep .vxe-table .vxe-body--column.col-red {
    color: red;
}
/deep/ tr.vxe-body--row.row-modify {
    color: blue !important;
}
/deep/ tr.vxe-body--row.row-new {
    color: #cc6600 !important;
}
</style>
